<template>
  <div class="gh-legend">
    <div
      class="gh-legend-circle"
      :style="{ backgroundColor: color }"
    ></div>
    <div
      class="gh-legend-name"
      :style="{
        width: `calc(100% - 13px - ${customWidth})`
      }"
    >
      {{ item.label || item.typeName }}
    </div>
    <div
      class="gh-legend-val"
      :style="{ width: customWidth }"
    >
      <span class="gh-legend-val-num">{{
        item.num || item.areaTotal || 0
      }}</span>
      {{ unit }}
    </div>
  </div>
</template>
<script>
export default {
  props: {
    item: {
      type: Object
    },
    color: {
      type: String
    },
    unit: {
      type: String,
      default: '公顷'
    },
    customWidth: {
      type: String,
      default: '80px'
    }
  },
  data() {
    return {}
  }
}
</script>
<style lang="scss">
.gh-legend {
  width: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  margin-bottom: 6px;
  &-circle {
    width: 8px;
    height: 8px;
    background: 000;
    border-radius: 4px;
    margin: 3px 5px 0 0;
  }
  &-name {
    width: calc(100% - 13px - 80px);
    word-break: break-all;
    font-size: 12px;
    line-height: 14px;
    font-weight: 400;
    color: #000000;
  }
  &-val {
    font-size: 12px;
    line-height: 14px;
    font-weight: 500;
    color: #4c565c;
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    width: 80px;
    &-num {
      font-size: 14px;
      font-family: DIN;
      font-weight: 500;
      color: #000000;
      margin: 0 5px 0px 0;
    }
  }
}
</style>
